<template>
	<view class="wrap yjfk-form-right">
		<u-form class="form" :model="model" :rules="rules" ref="uForm" label-position="top">
			<u-form-item label="问题和意见" prop="content">
				<u-input type="textarea" placeholder="请填写10个字以上的问题描述以便我们提供更好的帮助" v-model="model.content" height="200"
					maxlength="300" />
			</u-form-item>
			<u-form-item label="联系方式（手机、邮箱、QQ号码）" >
				<u-input class="input-left-form" placeholder="选填，便于我们与你联系，进一步沟通" v-modtel="model.contact" type="text"
					maxlength="40"></u-input>
			</u-form-item>
		</u-form>
		<view class="form-footer">
			<u-button class="btn" shape="circle" type="error" @click="submit" :ripple="true" ripple-bg-color="#d7d8da">
				提交
			</u-button>
			<!-- <u-button class="btn" type="primary" @click="submit">提交</u-button> -->
			<!-- <u-button class="btn" type="default" @click="cancel">关闭</u-button> -->
		</view>
	</view>
</template>
<script>
	/**
	 * Copyright (c) 2013-Now http://aidex.vip All rights reserved.
	 */
	export default {
		data() {
			return {
				model: {
					content: '',
					contact: '',
				},
				rules: {
					
					content: [{
						required: true,
						min: 10,
						max: 300,
						message: '问题和意见在 10 到 300 个字符之间',
						trigger: ['change', 'blur'],
					}],
				}
			};
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);

		},
		methods: {
			submit() {
				// console.log(this.model)
				this.$refs.uForm.validate(valid => {
					if (valid) {
						this.$u.api.feedbackRecord(this.model).then(res => {
							uni.showModal({
								title: '提示',
								content: res.msg,
								showCancel: false,
								success: function(res1) {
									if (res1.confirm ) {
										uni.navigateBack();
									}
								}
							});
						});
					} else {
						this.$u.toast('您填写的信息有误，请根据提示修正。');
					}
				});
			},
			cancel() {
				uni.navigateBack();
			}
		}
	};
</script>
<style lang="scss" scoped>
	.input-placeholder {
		text-align: right;
	}

	/deep/ .u-input__textarea {
		height: 100px !important;
		text-align: left !important;
	}
</style>
